#include "eeprom.h"
#include "ee_parameter.h"

ip_port_t localIP,remoteIP;

void EEP_ReadAll(void)
{
    uint16_t eepValue = 0;
    //10.200
    if(EE_ReadVariable(ADR_LOCAL_IPH, &eepValue)){
        localIP.ip.addr |= (((200<<24)|(11<<16))&0xFFFF0000);
    }else{
        localIP.ip.addr |= ((eepValue<<16)&0xFFFF0000);
    }

    //192.168
    if(EE_ReadVariable(ADR_LOCAL_IPL, &eepValue)){
        localIP.ip.addr |= (((168<<8)|(192))&0xFFFF);
    }else{
        localIP.ip.addr |= (eepValue&0xFFFF);
    }

    if(EE_ReadVariable(ADR_LOCAL_PORT, &eepValue)){
        localIP.port = 8090;
    }else{
        localIP.port = eepValue;
    }

    //10.63
    if(EE_ReadVariable(ADR_REMOTE_IPH, &eepValue)){
        remoteIP.ip.addr |= (((63<<24)|(11<<16))&0xFFFF0000);
    }else{
        remoteIP.ip.addr |= ((eepValue<<16)&0xFFFF0000);
    }

    //192.168
    if(EE_ReadVariable(ADR_REMOTE_IPL, &eepValue)){
        remoteIP.ip.addr |= (((168<<8)|(192))&0xFFFF);
    }else{
        remoteIP.ip.addr |= (eepValue&0xFFFF);
    }

    if(EE_ReadVariable(ADR_REMOTE_PORT, &eepValue)){
        remoteIP.port = 8089;
    }else{
        remoteIP.port = eepValue;
    }

}

void EEP_WriteParameter(uint16_t addr,uint16_t value)
{
    EE_WriteVariable(addr,value);
}


